# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-mirage-crypto
_pkgname=mirage-crypto
pkgver=0.10.6
pkgrel=0
pkgdesc="Simple symmetric cryptography for the modern age"
url="https://github.com/mirage/mirage-crypto"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="
	ocaml-runtime
	ocaml-cstruct
	ocaml-duration
	ocaml-eqaf
	ocaml-logs
	ocaml-mtime
	ocaml-zarith
	"
# ocaml-zarith is not separated into a -dev subpackage
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-cstruct-dev
	ocaml-duration-dev
	ocaml-eqaf-dev
	ocaml-logs-dev
	ocaml-mtime-dev
	"
makedepends="$depends_dev dune dune-configurator ocaml"
checkdepends="ocaml-ounit2-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirage/mirage-crypto/releases/download/v$pkgver/mirage-crypto-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build \
		-p mirage-crypto,mirage-crypto-ec,mirage-crypto-pk,mirage-crypto-rng \
		--verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit \
		mirage-crypto mirage-crypto-ec mirage-crypto-pk mirage-crypto-rng
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
870b7d0d32acde970afcd3fac2cb51131ac74bb20c887d07ddfccd239467a5dc8b700adf463427fa916393c503f106feb733cba5bf4b9d1f8eb57f52b5af9f9c  ocaml-mirage-crypto-0.10.6.tar.bz2
"
